
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.gson.Gson;

/**
 * Servlet implementation class consultar
 */
@WebServlet("/consultar")
public class consultar extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private Gson gson;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public consultar() {
		super();
		gson = new Gson();
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("application/json; charset=UTF-8");
		
		for (Reply rep: Dades.getQuery(0).getReplies()) {
			rep.setSelected(false);
		}
		
		response.getWriter().println(gson.toJson(Dades.getQuery(0)));
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
